package com.itheima_04;
/*
        同时获取最大值最小值：设计一个方法，能同时获取最大值和最小值
 */
public class getMaxMin {
    public static void main(String[] args) {
        int [] arr = {11, 33, 55, 77, 99, 22, 44, 66, 88};
        System.out.println("已知数组中元素如下：");
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i] + "\t");
        }
        System.out.println();
        getmaxmin(arr);
    }

    private static void getmaxmin(int[] arr) {
        int max = arr[0];
        int min = arr[0];
        for (int i = 0; i < arr.length; i++) {
            if (max < arr[i]) {
                max = arr[i];
            }
            if (min > arr[i]) {
                min = arr[i];
            }
        }
        System.out.println("max:\t" + max);
        System.out.println("min:\t" + min);
    }
}
